/**
 * Copyright (C), 2015-2020, 新华三技术有限公司
 * FileName: UserAttributesMapper
 * Author:   c10709
 * Date:     2020/12/1 22:53
 * Description: mapper
 * History:
 * <author>     <time>          <version>    <desc>
 * c10709      2020/12/1 22:53  v1.0        新建类
 */
package com.example.demo.ldap.support;


import com.example.demo.ldap.entity.User;
import org.springframework.ldap.core.AttributesMapper;

import javax.naming.NamingException;
import javax.naming.directory.Attributes;

/**
 * 〈一句话功能简述〉<br> 
 * 〈mapper〉
 *
 * @author c10709
 * @create 2020/12/1 22:53
 * @since 1.0.0
 */
public class UserAttributesMapper implements AttributesMapper<User> {

    @Override
    public User mapFromAttributes(Attributes attrs) throws NamingException {
        User person = new User();
        person.setCommonName((String)attrs.get("cn").get());
        person.setUserName((String)attrs.get("sn").get());
        person.setUid((String)attrs.get("uid").get());
        person.setDepartmentNumber((String)attrs.get("departmentNumber").get());
        person.setCahorganizationNumber((String)attrs.get("cahorganizationnumber").get());
        person.setMail((String)attrs.get("mail").get());
        return person;
    }
}